//
//  NSArrayAdditions.h
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface NSArray (Tint)

/*
 * Querying
 */
- (id)objectOrNilAtIndex:(NSUInteger)i;
- (id)firstObject;
- (id)randomObject;
- (BOOL)hasObjectEqualTo:(id)object;
- (BOOL)hasObjectIdenticalTo:(id)object;

/*
 * KVC
 */
- (NSArray *)newArrayWithUnionOfValues:(NSString *)keyPath;
- (NSArray *)newArrayWithObjectsForKeyPath:(NSString *)keyPath equalToValue:(id)value;
- (NSArray *)newArrayWithObjectsForKeyPath:(NSString *)keyPath identicalToValue:(id)value;
- (id)firstObjectForKeyPath:(NSString *)keyPath equalToValue:(id)value;
- (id)firstObjectForKeyPath:(NSString *)keyPath identicalToValue:(id)value;

/*
 * Sending messages
 */
- (void)makeObjectsRunSelector:(SEL)selector;

- (void)makeObjectsRunSelector:(SEL)selector 
                    withObject:(id)p1;

- (void)makeObjectsRunSelector:(SEL)selector 
                    withObject:(id)p1 
                    withObject:(id)p2;

- (void)makeObjectsRunSelector:(SEL)selector 
                    withObject:(id)p1 
                    withObject:(id)p2 
                    withObject:(id)p3;

- (void)makeObjectsRunSelector:(SEL)selector 
                    withObject:(id)p1 
                    withObject:(id)p2 
                    withObject:(id)p3 
                    withObject:(id)p4;

- (void)makeObjectsRunSelector:(SEL)selector 
                    withObject:(id)p1 
                    withObject:(id)p2 
                    withObject:(id)p3 
                    withObject:(id)p4 
                    withObject:(id)p5;

- (void)makeObjectsRunSelector:(SEL)selector 
                    withObject:(id)p1 
                    withObject:(id)p2 
                    withObject:(id)p3 
                    withObject:(id)p4 
                    withObject:(id)p5 
                    withObject:(id)p6;


- (void)makeObjectsRunSelectorOnMainThread:(SEL)selector;

- (void)makeObjectsRunSelectorOnMainThread:(SEL)selector 
                                withObject:(id)p1;

- (void)makeObjectsRunSelectorOnMainThread:(SEL)selector 
                                withObject:(id)p1 
                                withObject:(id)p2;

- (void)makeObjectsRunSelectorOnMainThread:(SEL)selector 
                                withObject:(id)p1 
                                withObject:(id)p2 
                                withObject:(id)p3;

- (void)makeObjectsRunSelectorOnMainThread:(SEL)selector 
                                withObject:(id)p1 
                                withObject:(id)p2 
                                withObject:(id)p3 
                                withObject:(id)p4;

- (void)makeObjectsRunSelectorOnMainThread:(SEL)selector 
                                withObject:(id)p1 
                                withObject:(id)p2 
                                withObject:(id)p3 
                                withObject:(id)p4 
                                withObject:(id)p5;

- (void)makeObjectsRunSelectorOnMainThread:(SEL)selector 
                                withObject:(id)p1 
                                withObject:(id)p2 
                                withObject:(id)p3 
                                withObject:(id)p4 
                                withObject:(id)p5 
                                withObject:(id)p6;

@end





@interface NSMutableArray (Tint)

/*
 * Adding and removing entries
 */
- (id)addObjectIfNotNil:(id)object;
- (id)addUnequalObjectIfNotNil:(id)object;
- (id)addUnidenticalObjectIfNotNil:(id)object;
- (id)insertObject:(id)object atIndexIfNotNil:(NSUInteger)index;
- (id)moveObjectAtIndex:(NSUInteger)index toIndex:(NSUInteger)toIndex;
- (void)removeFirstObject;

/*
 * Ordering and filtering
 */
- (void)shuffle;
- (void)reverse;
- (void)unequal;
- (void)unidentical;

/*
 * Stack
 */
- (id)push:(id)object;
- (id)pop;

/*
 * Queue
 */
- (id)enqueue:(id)object;
- (id)dequeue;

@end


